// 云函数入口文件
const cloud = require('qq-server-sdk');
const axios = require('axios');

cloud.init({
    env: cloud.DYNAMIC_CURRENT_ENV
})

// 云函数入口函数
exports.main = async(event, context) => {
    let i = "";
    await axios.get('https://api.q.qq.com/sns/jscode2session', {
            params: {
                appid: '11121695dd90',
                secret: "gTOqrA2uQYweddjMbSts",
                js_code: event.code,
                grant_type: "authorization_code"
            }
        })
        .then(function(response) {
            // handle success
            i = response.data;
        })
        .catch(function(error) {
            // handle error
        })
    return {
        data: i,
    }
}